package com.example.Dao;

import com.example.entity.Goods;
import com.example.entity.Goodstype;
import com.example.entity.Orders;
import com.example.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface OrdersDao {
    @Results({
            @Result(column = "uID",property = "users",javaType = Users.class,
                    one = @One(select = "com.example.Dao.UserDao.foundByID"))
    })
    @Select("select * from orders")
    ArrayList<Orders> queryAll();

    @Delete("delete from orders where oID = #{id}")
    int deleteByID(Integer id);

    @Select("select * from orders where oID = #{id}")
    Orders findById(Integer id);

    @Update("UPDATE orders SET " +
            "oTotal = #{orders.ototal}" +
            "WHERE oID = #{orders.oid}")
    int update(@Param("orders") Orders orders);

    @Insert("INSERT INTO orders" +
            "(uID,oTotal)" +
            "VALUES(#{orders.uid},#{orders.ototal})")
    int insert(@Param("orders") Orders orders);
}
